<?
    echo $this->messages();

    if (!$this->is_add)
        echo "<div class=\"spa_left left\">";
?>
<div class="subtitle">
    General Settings:
</div>
<div class="hr"></div>
<table>
    <tr>
        <td class="title">Provisioning enabled:</td>
        <td class="input_field"><input type="checkbox" id="spa_provisioning_enabled" value="" checked style="width: 20px;"/></td>
    </tr>
    <tr>
        <td class="title">Time Zone:</td>
        <td class="input_field"><input type="text" id="spa_time_zone" value="Time zone" /></td>
    </tr>
    <tr>
        <td class="title">Dictionary:</td>
        <td class="input_field"><input type="text" id="spa_dictionary" value="Dictionary" /></td>
    </tr>
    <tr>
        <td class="title">IP:</td>
        <td class="input_field">
            <select id="spa_ip">
<?
    foreach ($this->ip_not_in_use as $ip)
	{
?>
                <option value="<?=$ip ?>" <? if ($this->model_spa->getIP() == $ip) { echo " selected"; }?>><?=$ip ?></option>
<?
    };
?>
            </select>
        </td>
    </tr>
    <tr>
        <td class="title"> MAC:</td>
        <td class="input_field"><input type="text" id="spa_mac" value="<?=$this->model_spa->getMAC(); ?>" /></td>
    </tr>
    <tr>
        <td class="title">S/N:</td>
        <td class="input_field"><input type="text" id="spa_serial" value="<?=$this->model_spa->getSerial(); ?>" /></td>
    </tr>
</table>
<?
    if (!$this->is_add)
    {
?>
</div>
<div class="spa_right left">
    <div class="subtitle info">
        General Info:
    </div>
    <div class="hr"></div>
    <table>
        <tr>
            <td class="title">Provisioning status:</td>
            <td class="input_field"><?=$this->model_spa->getProvStatus(); ?></td>
        </tr>
        <tr>
            <td class="title">Last provisioned attempt:</td>
            <td class="input_field"><?=$this->model_spa->getLastProvAttempt(); ?></td>
        </tr>
        <tr>
            <td class="title">Last successfull provisioning:</td>
            <td class="input_field"><?=$this->model_spa->getLastProv(); ?></td>
        </tr>
        <tr>
            <td class="title">Last taken firmware:</td>
            <td class="input_field"><?=$this->model_spa->getLastFirmware(); ?></td>
        </tr>
        <tr>
            <td class="title">Last provisioning message:</td>
            <td class="input_field"><?=$this->model_spa->getLastProvMsg(); ?></td>
        </tr>
    </table>
</div>
<div class="clear"></div>
<?
    };
?>
<br><br>
<?
    for ($i = 0; $i < $this->model_spa->getModelType()->getExts(); $i++)
    {
?>
<div class="subtitle">
    Ext <?=($i + 1)?>:
</div>
<div class="hr"></div>
<table>
    <tr>
        <td class="title">Company:</td>
        <td class="input_field">
            <select id="company_id_<?=$i ?>" onchange="event_onChange_CompanyID(<?=$i ?>)">
                <option value="-1">Empty</option>
<?
        foreach ($this->collection_company as $model_company)
        {
?>
                <option value="<?=$model_company->getID(); ?>"
                    <? if ($this->model_spa->getModelAccount($i)->getModelCompany()->getID() == $model_company->getID()) { echo "selected"; } ?>
                >
                        <?=$model_company->getCaption(); ?>
                </option>
<?
        };
?>
            </select>
        </td>
    </tr>
    <tr>
    <td class="title">Account:</td>
    <td class="input_field">
        <select id="spa_ext_<?=$i ?>">
            <option value="-1">Empty</option>
<?
        foreach ($this->model_spa->getModelAccount($i)->getModelCompany()->getAccountCollection() as $model_account)
        {
?>
            <option value="<?=$model_account->getID() ?>" <? if ($this->model_spa->getModelAccount($i)->getID() == $model_account->getID()) { echo "selected"; } ?>>
            <?="Login: ".$model_account->getLogin()." (Display name: ".$model_account->getDisplayName()."; Short name: ".$model_account->getShortName(); ?>)
            </option>
<?
        };
?>
            </select>
        </td>
    </tr>
</table>
<br>
<?
    };
?>
<?=$this->buttons(); ?>